import { http } from '@/utils/http'

export interface MyTrainItem {
  cover: string
  trainname: string
  Address: string
  starttime: string
}
export interface MyTrainListParams {
  showFlag?: number
  deptId?: number
  trainName?: string
  teacherName?: string
  startTime?: string
  endTime?: string
  page?: number
  limit?: number
  key?: string
}

/* 我的培训-分页 */
export const myTrainList = ({
  showFlag,
  deptId,
  trainName,
  teacherName,
  startTime,
  endTime,
  page = 1,
  limit = 10,
  key = '',
}: MyTrainListParams = {}): Promise<IResData<MyTrainItem[]>> => {
  return http.get<MyTrainItem[]>('/api/MP/GetMyTrainList', {
    showFlag,
    deptId,
    trainName,
    teacherName,
    startTime,
    endTime,
    page,
    limit,
    key,
  })
}

/* 我的考试 */
export interface MyExamListParams {
  title?: string
  start?: string
  end?: string
  isPassed?: number
  examStatus?: number // 考试状态 0:未开始 1:未提交 2:已提交 3:已批阅
  page?: number
  limit?: number
  key?: string
}

export interface MyExamItem {
  examinationId: number
  examTitle: string
  paperId: number
  beginTime: string
  endTime: string
  timeLength: number
  isPrecent: number
  showMode: number
  allowTimes: number
  randomOrderMode: number
  isOpenAnswer: number
  isOpenScore: number
  passmark: number
  sendMessageMode: number
  examRules: string
  approvalUsers: string
  isPublished: number
  isReadOver: number
  isPublishScore: number
  allowLeaveTimes: number
  isAntiCheating: number
  isAutoMarking: number
  userID: number
  createTime: string
  isDeleted: number
  testCredit: string
  examSortId: number
  roleTags: string
}

export interface MyExamData {
  totalCount: number
  items: MyExamItem[]
}

export const myExamList = ({
  title,
  start,
  end,
  isPassed,
  examStatus,
  page = 1,
  limit = 10,
  key,
}: MyExamListParams = {}): Promise<IResData<MyExamData>> => {
  return http.get<MyExamData>('/api/MP/GetMyExamList', {
    title,
    start,
    end,
    isPassed,
    examStatus,
    page,
    limit,
    key,
  })
}

/* 我的消息 */
export interface MyMessageListParams {
  title?: string
  starttime?: string
  endtime?: string
  sendrealname?: string
  recstatus?: number
  page?: number
  limit?: number
}

export interface MyMessageItem {
  recStatusstr: string
  title: string
  createTime: string
  messageContent: string
  recordId: number
  messageId: number
  sendUserId: number
  recUserId: number
  recResoureId: number
  sendStatus: number
  recStatus: number
  msgType: number
}

export interface MyMessageData {
  totalCount: number
  items: MyMessageItem[]
}

/* 我的消息 */
export const myMessageList = ({
  title,
  starttime,
  endtime,
  sendrealname,
  recstatus, // 0未读 1已读
  page = 1,
  limit = 10,
}: MyMessageListParams = {}): Promise<IResData<MyMessageData>> => {
  return http.get<MyMessageData>('/api/MP/GetMyMessageList', {
    title,
    starttime,
    endtime,
    sendrealname,
    recstatus,
    page,
    limit,
  })
}
